<%@ page contentType="text/html;charset=UTF-8" %>
<%@include file="/WEB-INF/views/include/taglib.jsp" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <%@include file="/WEB-INF/views/include/top.jsp" %>
    <style type="text/css">
	    .panel-default {
	    	border-color: #fff;
		}
    </style>
    <title>其它设置</title>
</head>
<body>
<input type="hidden" id="contentVal" value='${otherDto.content }' />
<div class="rightBody">
    <div class="SetUpBody">
		<div class="page-content">
			<div class="container">
				<div class="panel panel-default">
					<div class="panel-body">
						<form class="form-horizontal"  autocomplete="off">
							<div class="form-group">
								<label class="col-sm-3 control-label">标题</label>
								<div class="col-sm-9">
									<input type="text"class="form-control" name="title" id="title"  value="${otherDto.title }" placeholder="请输入功能排序">
								</div>
							</div>
							<div class="form-group" align="center">
								<script  id="editor" type="text/plain" ></script>
							</div>
						</form>
					</div>
					<div class="modal-footer">
						<button id="save"  type="submit"  class="btn btn-primary" >保存</button>
						<button type="button" data-dismiss="modal" class="btn btn-default">返回</button>
					</div>
				</div>
			</div>
		</div>
	<script src="${ctxAssets}/js/lib/jquery/jquery-1.10.2.js"></script>
	<script src="${ctxAssets}/js/lib/jquery-validation/1.11.1/jquery.validate.min.js"></script>
	<script type="text/javascript" charset="utf-8" src="${ctx}/admin/ueditor/ueditor.config.js"></script>
	<script type="text/javascript" charset="utf-8" src="${ctx}/admin/ueditor/ueditor.all.min.js"> </script>
	<script type="text/javascript" charset="utf-8" src="${ctx}/admin/ueditor/lang/zh-cn/zh-cn.js"></script>
	<script type="text/javascript">
		    //实例化编辑器
		    //建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
		    var ue = UE.getEditor('editor',{initialFrameHeight:500});
			function getContent() {return UE.getEditor('editor').getContent();}
			function getLocalData () {alert(UE.getEditor('editor').execCommand( "getlocaldata" ));}
			function clearLocalData () {UE.getEditor('editor').execCommand( "clearlocaldata" );alert("已清空草稿箱")}
			$(window).resize(function(){
			   $("#edui1").width($("#editor").width());
		   	});
			$(function(){
				var ue = UE.getEditor('editor');  
				var contentVal=$("#contentVal").val();
				ue.ready(function() {//编辑器初始化完成再赋值  
					ue.setContent(contentVal);  //赋值给UEditor  
				}); 
			});
	        function notifyInfo(msg, type) {
	        	if(type){
	        		alert('修改成功');
	        	}else{
	        		alert('修改失败');
	        	}
	        }
		   
		   var webRoot = G_WEB_ROOT;
			  var urls = {
				        getMenuAndTypeUrl: webRoot + "/admin/ueditor/queryMenuAndType.do",
				        saveUrl: webRoot + "/sys/updateAbout.do"
				    };
			  
			  $('.form-horizontal').validate({
		          errorElement: 'span',
		          errorClass: 'help-block',
		          focusInvalid: false,
		          rules: { 'title': { required: true }},
		          messages: {'title': {required: "功能名称必须填写!"}},
		          highlight: function (element) {
		              $(element).closest('.form-group').addClass('has-error');
		          },
		          success: function (label) {
		              label.closest('.form-group').removeClass('has-error');
		              label.remove();
		          },
		          errorPlacement: function (error, element) {
		              element.parent('div').append(error);
		          },
		          submitHandler: function (form) {}
		      });
		
			$("#save").click(function(){
				  if($('.form-horizontal').valid()){
				   	 var data={
				   			id:2,
				   			content:getContent(),
				   			title:$("#title").val()
				   		}
				   	     $.ajax({
				   	         url: urls.saveUrl,
				   	         type: 'post',
				   	         data:  data,
				   	         success: function (data) {
				   	             notifyInfo(data.msg, data.type);
				   	         }
				   	     });
				  }
			});
		  	$.ajax({
		        url: urls.getMenuAndTypeUrl,
		        type: 'post',
		        async: false,
		        success: function(data) {
		        	$.each(data.module,function(){
		        		$("#moduleId").append($("<option value='"+this.moduleId+"'>"+this.moduleName+"</option>"));
		        	});
		        	$.each(data.navigate,function(){
		        		$("#navigateId").append($("<option value='"+this.navigateId+"'>"+this.name+"</option>"));
		        	});
		        }
		    });
	</script>
    </div>
</div>

</body>
</html>